package module4;

public class Ticket2 implements Runnable{
    private int tickets = 100;
    @Override
    public void run() {
        while (true){
            synchronized (this){
                if (tickets <=0){
                    break;
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "还剩" + tickets-- + "张票");
            }
        }
    }
}
